package com.txunda.zhuohired.fgt.manage;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.ants.theantsgo.gson.GsonUtil;
import com.ants.theantsgo.util.L;
import com.bumptech.glide.Glide;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.lidroid.xutils.view.annotation.event.OnClick;
import com.txunda.zhuohired.R;
import com.txunda.zhuohired.aty.manage.my.ManageAdvertisBuyAty;
import com.txunda.zhuohired.aty.manage.my.ManageCompanyAty;
import com.txunda.zhuohired.aty.manage.my.ManageDisplayAty;
import com.txunda.zhuohired.aty.manage.my.ManageResumeCollectAty;
import com.txunda.zhuohired.aty.manage.my.ManageResumeDateAty;
import com.txunda.zhuohired.base.BaseFgt;
import com.txunda.zhuohired.bean.manage.my.ManageInfoBean;
import com.txunda.zhuohired.http.pst.UserPst;
import com.txunda.zhuohired.util.GlideCircleTransform;

/**
 * 创建人： Txd_Cjh
 * 创建时间： 2018/3/10 14:32
 * 功能描述：我的
 * 联系方式：jiahuanchen@126.com
 */

public class ManageMyFgt extends BaseFgt {
    /**
     * 返回键
     */
    @ViewInject(R.id.iv_layout_blue_back)
    private ImageView iv_layout_blue_back;
    /**
     * 企业头像
     */
    @ViewInject(R.id.iv_manage_logo)
    private ImageView iv_manage_logo;
    /**
     * 企业名称
     */
    @ViewInject(R.id.tv_manage_name)
    private TextView tv_manage_name;
    /**
     * 行业和规模
     */
    @ViewInject(R.id.tv_trade_scale)
    private TextView tv_trade_scale;
    /**
     * 面试日程
     */
    @ViewInject(R.id.tv_interview_plan)
    private TextView tv_interview_plan;
    /**
     * 面试申请
     */
    @ViewInject(R.id.tv_interview)
    private TextView tv_interview;
    /**
     * 简历收藏
     */
    @ViewInject(R.id.tv_resume_collect)
    private TextView tv_resume_collect;

    private UserPst userPst;
    private String token;
    private int user_id;
    @Override
    @OnClick({R.id.tv_manage_my_detail, R.id.ll_manage_my_date, R.id.ll_manage_my_resume, R.id.tv_manage_my_details,
            R.id.tv_manage_my_buy})
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()) {
            case R.id.tv_manage_my_detail://公司信息
                startActivity(ManageCompanyAty.class, null);
                break;
            case R.id.ll_manage_my_date://面试日程
                startActivity(ManageResumeDateAty.class, null);
                break;
            case R.id.ll_manage_my_resume://简历收藏

                startActivity(ManageResumeCollectAty.class, null);
                break;
            case R.id.tv_manage_my_details://主页展示
                startActivity(ManageDisplayAty.class, null);
                break;
            case R.id.tv_manage_my_buy://广告位购买
                startActivity(ManageAdvertisBuyAty.class, null);
                break;
        }
    }

    @Override
    protected void immersionInit() {
        showStatusBar(R.id.layout_blue_head);
        iv_layout_blue_back.setVisibility(View.GONE);
    }

    @Override
    protected int getLayoutResId() {
        return R.layout.fgt_manage_my;
    }

    @Override
    protected void initialized() {
        userPst = new UserPst(this);
        token = application.getUserInfo().get("data");
    }

    @Override
    protected void requestData() {
        userPst.showInfo(token);
    }

    @Override
    public void onComplete(String requestUrl, String jsonStr) {
        super.onComplete(requestUrl, jsonStr);
        if(requestUrl.contains("showInfo")){
            L.e("====showInfo=====",jsonStr);
            ManageInfoBean manageInfoBean = GsonUtil.GsonToBean(jsonStr,ManageInfoBean.class);

            tv_manage_name.setText(manageInfoBean.getData().getCompany_name());
            tv_trade_scale.setText("行业：  "+manageInfoBean.getData().getTrade_name()
                    +"   规模:   "+manageInfoBean.getData().getScale_name());
            tv_interview.setText(manageInfoBean.getData().getInterview_num());
            tv_interview_plan.setText(manageInfoBean.getData().getInterview_plan_num());
            tv_resume_collect.setText(manageInfoBean.getData().getResume_collect_num());
            Glide.with(this).load(manageInfoBean.getData().getCompany_logo())
                    .dontAnimate()
                    .error(R.mipmap.default_image)
                    .placeholder(R.mipmap.default_image)
                    .transform(new GlideCircleTransform(getContext()))
                    .into(iv_manage_logo);
        }

    }
}
